//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package org.quickserver.net.GB268753QN.control;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.quickserver.net.model.DevType;
import org.quickserver.net.model.GB268753QN;
import org.quickserver.net.model.GBServerData;
import org.quickserver.net.server.ClientHandler;
import org.quickserver.util.data.dataProcessing;

public class QNA2B122 {
    public QNA2B122() {
    }

    public static GB268753QN QNA2B122OBJ(ClientHandler handler, String[] strs, int dataLength) {
        GBServerData ec = (GBServerData)handler.getClientData();
        GB268753QN GBQN = new GB268753QN();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String[] stateTime;
        String[] WhQh;
        String[] str;
        String zwstr;
        if (dataLength == 28) {
            stateTime = new String[]{strs[22], strs[23], strs[24], strs[25], strs[26], strs[27]};
            WhQh = new String[]{strs[5], strs[6], strs[7], strs[8]};
            str = dataProcessing.reInfo("0101", WhQh);
            GBQN.setUniqueCode(ec.getUniqueCode());
            GBQN.setUploadTime(sdf.format(new Date()));
            GBQN.setStateTime(dataProcessing.strsToTime(stateTime));
            GBQN.setSysType(String.valueOf(dataProcessing.hexStringToInt10(strs[2])));
            GBQN.setIsComponent("2");
            GBQN.setSysAddress(String.valueOf(dataProcessing.hexStringToInt10(strs[3])));
            GBQN.setComponentType(String.valueOf(dataProcessing.hexStringToInt10(strs[12])));
            Map<String, String> map = new HashMap();
            map.put(DevType.ywzc.getCode(), DevType.ywzc.getName());
            GBQN.setComponentStateMap(map);
            GBQN.setLoopNumber(str[1]);
            GBQN.setComponentNumber(str[2]);//模块
            zwstr = String.valueOf(dataProcessing.hexStringToInt10(strs[11]));
            GBQN.setTd(zwstr);
            //String id = GBQN.getUniqueCode() + "-" + str[0] + "-" + str[1] + "-" + str[2] + "-" + zwstr;
            String id = GBQN.getUniqueCode() +"-"+ str[2] +"-"+ zwstr;
            GBQN.setId(id);
        } else {
            stateTime = new String[]{strs[37], strs[38], strs[39], strs[40], strs[41], strs[42]};
            WhQh = new String[]{strs[5], strs[6], strs[7], strs[8]};
            str = dataProcessing.reInfo("0101", WhQh);
            String[] zw = dataProcessing.strsToStrs(strs, 22, 36);
            zwstr = dataProcessing.gB18030ByteArrayToUtf8String(dataProcessing.hexStringsToByteArray(zw));
            Map<String, String> map = new HashMap();
            if (zwstr.indexOf("高限") != -1) {
                map.put(DevType.ywgx.getCode(), zwstr.trim());
            } else {
                map.put(DevType.ywdx.getCode(), zwstr.trim());
            }

            GBQN.setUniqueCode(ec.getUniqueCode());
            GBQN.setUploadTime(sdf.format(new Date()));
            GBQN.setStateTime(dataProcessing.strsToTime(stateTime));
            GBQN.setSysType(String.valueOf(dataProcessing.hexStringToInt10(strs[2])));
            GBQN.setIsComponent("2");
            GBQN.setSysAddress(String.valueOf(dataProcessing.hexStringToInt10(strs[3])));
            GBQN.setComponentType(String.valueOf(dataProcessing.hexStringToInt10(strs[12])));
            GBQN.setComponentStateMap(map);
            GBQN.setLoopNumber(str[1]);
            GBQN.setComponentNumber(str[2]);//模块
            String td = String.valueOf(dataProcessing.hexStringToInt10(strs[11]));
            GBQN.setTd(td);
            //String id = GBQN.getUniqueCode() + "-" + str[0] + "-" + str[1] + "-" + str[2] + "-" + td;
            String id = GBQN.getUniqueCode() + "-" + str[2] + "-" + td;
            GBQN.setId(id);
        }

        return GBQN;
    }
}
